package com.sky.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;

@Configuration
public class RedisTemplateConfiguration {
    //构建一个RedisTemplate对象交给ioc容器管理

    @Bean
    public RedisTemplate redisTemplate(RedisConnectionFactory factory){

        RedisTemplate template = new RedisTemplate();

        //给key   设置序列化集：
        template.setKeySerializer(new StringRedisSerializer());

        //设置连接工程
        template.setConnectionFactory(factory);

        return template;
    }
}
